package com.ruoyi.web.controller.wfshou;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.wfshou.domain.Logistics;
import com.ruoyi.wfshou.service.ILogisticsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 物流技术类Controller
 * 
 * @author zongying
 * @date 2023-06-19
 */
@RestController
@RequestMapping("/wfshou/logistics")
public class LogisticsController extends BaseController
{
    @Autowired
    private ILogisticsService logisticsService;

    /**
     * 查询物流技术类列表
     */
    @PreAuthorize("@ss.hasPermi('wfshou:logistics:list')")
    @GetMapping("/list")
    public TableDataInfo list(Logistics logistics)
    {
        startPage();
        List<Logistics> list = logisticsService.selectLogisticsList(logistics);
        return getDataTable(list);
    }
    @GetMapping("/listAll")
    public TableDataInfo listAll()
    {
        List<Logistics> list = logisticsService.selectLogisticsList(null);
        return getDataTable(list);
    }
    /**
     * 导出物流技术类列表
     */
    @PreAuthorize("@ss.hasPermi('wfshou:logistics:export')")
    @Log(title = "物流技术类", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Logistics logistics)
    {
        List<Logistics> list = logisticsService.selectLogisticsList(logistics);
        ExcelUtil<Logistics> util = new ExcelUtil<Logistics>(Logistics.class);
        util.exportExcel(response, list, "物流技术类数据");
    }

    /**
     * 获取物流技术类详细信息
     */
    @PreAuthorize("@ss.hasPermi('wfshou:logistics:query')")
    @GetMapping(value = "/{logisId}")
    public AjaxResult getInfo(@PathVariable("logisId") Long logisId)
    {
        return success(logisticsService.selectLogisticsByLogisId(logisId));
    }

    /**
     * 新增物流技术类
     */
    @PreAuthorize("@ss.hasPermi('wfshou:logistics:add')")
    @Log(title = "物流技术类", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Logistics logistics)
    {
        return toAjax(logisticsService.insertLogistics(logistics));
    }

    /**
     * 修改物流技术类
     */
    @PreAuthorize("@ss.hasPermi('wfshou:logistics:edit')")
    @Log(title = "物流技术类", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Logistics logistics)
    {
        return toAjax(logisticsService.updateLogistics(logistics));
    }

    /**
     * 删除物流技术类
     */
    @PreAuthorize("@ss.hasPermi('wfshou:logistics:remove')")
    @Log(title = "物流技术类", businessType = BusinessType.DELETE)
	@DeleteMapping("/{logisIds}")
    public AjaxResult remove(@PathVariable Long[] logisIds)
    {
        return toAjax(logisticsService.deleteLogisticsByLogisIds(logisIds));
    }
}
